import React from "react";
import { Redirect, Link } from "react-router-dom";

export default function Home({ location }) {
  if (!location.state) {
    // return <Redirect to="/login/code" />;
    return (
      <div>
        <h1>hello</h1>
        <Link to="/login/code">登录</Link>
      </div>
    );
  }

  const { username, avatar } = location.state;

  return (
    <div>
      <h1>{username}</h1>
      <img src={avatar} alt="avatar" />
    </div>
  );
}
